import time
from common.base import Base, By
from common.functions import open_browser


class BackgroundLoginPage(Base):
    backgroundlogin_url = 'http://139.129.26.163/admin/privilege.php?act=login'

    def input_username(self):
        self.find_ele((By.NAME, 'username')).send_keys('admin')

    def input_password(self):
        self.find_ele((By.NAME, 'password')).send_keys('admin123')

    def remember(self):
        self.find_ele((By.ID,'remember')).click()

    def submit(self):
        self.find_ele((By.CLASS_NAME, 'btn-a')).click()


if __name__ == '__main__':
    browser = open_browser()
    b1 = BackgroundLoginPage(browser)
    b1.get('http://139.129.26.163/admin/privilege.php?act=login')
    b1.input_username()
    b1.input_password()
    b1.remember()
    time.sleep(2)
    b1.submit()
    b1.quit()
